const http = require('http');
const fs =  require('fs');
let server = http.createServer((req,res) =>{
    console.log(req.url);
    res.setHeader('content-type','text/html;charset=utf-8');
    if (req.url == "/") {  // 路由地址
        let data = fs.readFileSync("./views/index.html");// 通过fs模块把html文件内容读取出来了
        //    console.log(data.toString());
        res.write(data);
        res.end();
    }else if(req.url=="/product"){
        let data = fs.readFileSync("./views/product.html");// 通过fs模块把html文件内容读取出来了
        //    console.log(data.toString());
        res.write(data);
        res.end();
    }
})
server.listen(8080);